<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>获取一个偏移位置的值</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="arrayaccess.offsetexists.html">ArrayAccess::offsetExists</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="arrayaccess.offsetset.html">ArrayAccess::offsetSet</a></div>
 <div class="up"><a href="class.arrayaccess.html">数组式访问</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="arrayaccess.offsetget" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ArrayAccess::offsetGet</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.0.0)</p><p class="refpurpose"><span class="refname">ArrayAccess::offsetGet</span> &mdash; <span class="dc-title">获取一个偏移位置的值</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-arrayaccess.offsetget-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">abstract</span> <span class="modifier">public</span> <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <span class="methodname"><strong>ArrayAccess::offsetGet</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$offset</code></span>
   )</div>

  <p class="para rdfs-comment">
   返回指定偏移位置的值。
  </p>
  <p class="para">
   当检查一个偏移位置是否为 <span class="function"><a href="function.empty.html" class="function">empty()</a></span> 时，此方法被执行。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-arrayaccess.offsetget-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">offset</code></em></dt>

     <dd>

      <p class="para">
       需要获取的偏移位置。
      </p>
     </dd>

    
   </dl>

  </p>

 </div>


 <div class="refsect1 notes" id="refsect1-arrayaccess.offsetget-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
    <p class="para">
      Starting with PHP 5.3.4, the prototype checks were relaxed and it&#039;s
      possible for implementations of this method to return by reference.
      This makes indirect modifications to the overloaded array dimensions of
      <strong class="classname">ArrayAccess</strong> objects possible.
    </p>
    <p class="para">
      A direct modification is one that replaces completely the value of
      the array dimension, as in <em>$obj[6] = 7</em>. An
      indirect modification, on the other hand, only changes part of the
      dimension, or attempts to assign the dimension by reference to
      another variable, as in <em>$obj[6][7] = 7</em> or
      <em>$var =&amp; $obj[6]</em>. Increments with
      <em>++</em> and decrements with <em>--</em>
      are also implemented in a way that requires indirect modification.
    </p>
    <p class="para">
      While direct modification triggers a call to
      <span class="function"><a href="arrayaccess.offsetset.html" class="function">ArrayAccess::offsetSet()</a></span>, indirect modification
      triggers a call to <span class="function"><strong>ArrayAccess::offsetGet()</strong></span>.
      In that case, the implementation of
      <span class="function"><strong>ArrayAccess::offsetGet()</strong></span> must be able to return by
      reference, otherwise an <strong><code>E_NOTICE</code></strong> message is raised.
    </p>
  </p></blockquote>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-arrayaccess.offsetget-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   可返回任何类型。
  </p>
 </div>




 <div class="refsect1 seealso" id="refsect1-arrayaccess.offsetget-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="arrayaccess.offsetexists.html" class="methodname" rel="rdfs-seeAlso">ArrayAccess::offsetExists()</a> - 检查一个偏移位置是否存在</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="arrayaccess.offsetexists.html">ArrayAccess::offsetExists</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="arrayaccess.offsetset.html">ArrayAccess::offsetSet</a></div>
 <div class="up"><a href="class.arrayaccess.html">数组式访问</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
